package com.shop.zookeeper.zookeeper;

import org.I0Itec.zkclient.ZkClient;
import org.apache.zookeeper.CreateMode;

/**
 * @author Song Yinghui
 * @date 2019/12/6
 * @Version 1.0
 */
public class ZkClientTest {

    static ZkClient zkClient = new ZkClient("120.27.243.49:2181");

    public static void createNode(){

//        String s = zkClient.create("/song", "120.27.243.49", CreateMode.PERSISTENT);
//        System.out.println(s);
        zkClient.createPersistent("/song/serve","120.27.243.49");
    }

    //临时节点
    public static void createEphemeralNode(){
//        zkClient.create(CreateMode.EPHEMERAL)
        zkClient.createEphemeral("/test","ephem");
    }

    public static void main(String[] args) {
        //createNode();
        createEphemeralNode();
        try {
            Thread.sleep(Integer.MAX_VALUE);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
